<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            width: 100vw;
            height: 100vh;
        }

        .tabs {
            width: 800px;
            height: 100px;
        }

        .tab {
            box-sizing: border-box;
            width: 200px;
            height: 100px;
            border: 1px solid black;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.3vw;
        }

        .tab.active {
            background-color: red;
        }
    </style>
</head>

<body>
    <!-- <div class="tabs">
        <div class="tab active">1</div>
        <div class="tab">2</div>
        <div class="tab">3</div>
        <div class="tab">4</div>
    </div> -->

    <script>
        function Tabs() {
            let tabs = document.createElement('div');
            let tabList = [];
            tabs.classList.add('tabs');
            document.body.appendChild(tabs);

            for (let i = 0;i<4;i++) {
                let tab = document.createElement('div');
                tab.innerHTML = i+1;
                tab.classList.add('tab');
                tabs.appendChild(tab);
                tabList.push(tab);

                tab.onclick = function(){
                    tabList.forEach(item=>item.classList.remove('active'));
                    tab.classList.add('active');
                }
            }
        }

        Tabs.prototype.change = function(){
            
        }

        new Tabs();
    </script>
</body>

</html>